package 贪心;

import java.util.Arrays;
import java.util.Comparator;
import java.util.LinkedList;

/**
 * @ClassName _406根据身高重建队列
 * @Description TODO
 * @Author 昝亚杰
 * @Date 2021/12/22 20:11
 * Version 1.0
 **/
public class _406根据身高重建队列 {
    public static void main(String[] args) {
    }
    public static  int[][] reconstructQueue(int[][] people) {
        Arrays.sort(people, new Comparator<int[]>() {
            @Override
            public int compare(int[] o1, int[] o2) {
                if(o1[0] != o2[0]){
                    return o1[0] < o2[0] ? 1 : -1;
                }else {
                    return o1[1] > o2[1] ? 1 : -1;
                }
            }
        });
        LinkedList<int []> queue = new LinkedList();
        for(int[] a : people){
            queue.add(a[1],a);
        }
        return queue.toArray(new int[people.length][]);
    }
}
